Image Processing:
    General Handling | Import / Export | Viewing | Geometrical Transformations | Color Manipulations |

    Color Manipulations

    - insert a smart subtitle here ;-) -

    Let's start again with an RGB image.

    (  1)>image=read_targa("mailbox.tga");
    
    Since this picture was raytraced, it has far to much colors. Let's reduce them first.
    (  2)>less=color_reduce(image,\colors=62,\floyd);
    
    The resulting array less contains an RGB-image with at least 64 colors. Alternativly one could use a predefined colormap. Xi will then adjust the image to the colormap.
    (  3)>colormap=rainbow(62);
    (  4)>less=color_reduce(image,colormap,\floyd);
    
    In the next step the RGB image less can be transformed into a colormap based one.
    (  5)>[pixelmap,colormap]=rgb2map(less);
    
    As you can see in line 5 the rgb2map function has two return values - the pixelmap (Rows x Cols dimensional array) and the colormap (numberColors x 3 dimensional array). Of course you could reverse this process.
    (  6)>less=map2rgb(pixelmap,colormap);
    

    Furthermore it is possible to transform a RGB image to a gray scaled image.

    (  7)>gray=rgb2grayscale(image); 
    
    To generate the corresponding colormap use the graymap command
    (  8)>gray_map=graymap(256);
    
    The function
    (  9)> gam=gammaCorr(image,\r=0.5,\g=1.2,\b=1.3);
    
    performs a gamma correction of an image. Here the parameters r, g and b specify the gamma values for each color to use. A value of 1.0 leaves the image alone (default) , less than one darkens it, and greater than one lightens it.

    The function nonLinearFilters is something of a swiss army knife filter. Parameters are alpha and radius. For detailed information see the language reference or the manpages to the command pnmnfilt.

    ( 10)>pn=nonLinearFilters(image,\alpha=0.3,\radius=0.9);
    
    The function brighten changes the images Saturation and Value. It gets a RGB or colorbased image as input converts the image from RGB space to HSV space and changes the saturation and value (parameters are given in percent).
    ( 11)>br=brighten(image,\saturation=50,\value=20);
    

    Xi can be also used to enhance the contrast of an image. The standard technique for this is the histogram equalization.

    ( 12)h=hist_equal(image);
    

    To change from RBG to HSV color system, use the rgb2hsv command.

    ( 13)>hsv=rgb2hsv(colormap);
    ( 13)>colormap=hsv2rgb(hsv);
    
    Here the result is an (Nx3) array based on hue, saturation and value. Hue is usually represented as a 260-degree color wheel. Saturation refers to how pure a color is and value corresponds to the intensity of the color (Have a look at the source code of the function rainbow in your xilib directory to see an example).

    Use the functions rgb2yuv and yuv2rgb in the same way to change between RGB and Abekas YUV.


    Rechts Index Index Index Linls © 1995 by Bodo Junglas, Klaus Spanderen and Fabian Weis
    - Last revised: April 23 1996